/*****************************************************************
**                                                              **
**  Copyright (C) 2005 Amlogic,Inc.                             **
**  All rights reserved                                         **
**        Filename : aw_pic_app.c /Project:AVOS                **
**        Revision : 1.0                                        **
**                                                              **
*****************************************************************/
#include <sys/types.h>

#include "../user.h"
#include "aw_PIC_app.h"
#include "pic_define.h"
#include "menu.h"
#include <aw_playlist2.h>
#include "./win/WinPicInfoBarEvent.h"
#include "./win/Win15PicEvent.h"
#include "logo_dat.h" 
#include "aw_init_display.h"
#include "aw_gui_app.h"
#include "aw_sys_app.h"
#include "aw_GPLAYER_app.h"
#include "aw_init_display.h"
#include "datasrc.h"
#include "fs_playlist.h"
#include "aw_pic_util.h"
#include "aw_config.h"
#include "ctrlconvert.h"
#include "./win/NetmenuSetupEvent.h"
#include "./win/LogoEvent.h"
#include <Drivers/display/decoder/show_command.h>

#ifdef ENABLE_BLUETOOTH
#include "aw_bluetooth.h"
#include <Drivers/bluetooth/bt_customer.h>
#endif

#ifdef ENABLE_BLUETOOTH_OPP
unsigned char bt_play_flag = 0;
unsigned char bt_pic_flag = 0;
unsigned char Quit_flag=1;
extern char nand_name[16];
#endif

pic_disp_detail_info infos[48];
Playlist_t *Fplaylist;
pic_disp_info_t jpginfo;
pic_extra_info_t pic_extra_info = {0 ,0,0};
MemoryDataSrc data_src;
pic_time pictime;
StandardTime Time;

#define PIC_STATUS_RUNNING    0
#define PIC_STATUS_QUITTING   1
#define PIC_STATUS_SWITCHING  2
#define PIC_STATUS_SKIPPING   3

//INT32S TotalPicNum = 0;
//INT8U  Music_Pic_mix_flag = 0 ;
char SixPicName[256];
char FomatName[256];
char SixPicNumInfo[20];
char PicInfoBarFileName[256];
char ShowTime[19];
unsigned char picshowtime[20];
int pic_play_status = 0;
int audio=0;
int uop_angle_flag=0;
int select_change_flag =0 ; 
int aw_curwin_num = 0;
int aw_title_mode;
int aw_title_num = 0 ;
int pic_show_mode = -1;
int SWITCH_MP3_PICINFO_FLAG=0;
int restore_key = 0;
int rotatelevel=0; 
int frame_direction=0;
int SHOW_WINDOW_NUM;
int SIXPIC_ROW_TOTAL;
int SIXPIC_LINE_TOTAL;
INT8U pic_zoom_flag=0;
INT8U last_pic_del_quit_flag=0;
INT8U Angle;
INT8U  Music_Pic_mix_flag = 0 ;
INT8U title_flag=0;
INT8U PicDefineMode_flag=0;
INT32S TotalPicNum = 0;
INT32U Pic_Decode_Percent = 0 ;

static INT8U pic_playmode = 0;
static INT8U quit_flag = 0;

#ifdef ZOOM_IN
extern int reduce_level;
#endif
extern AVTimer_t auto_play_timer_3 ;
extern AVTimer_t auto_play_timer ;
extern int MultiMenuToSingle;
extern int uop_home_flag;
extern int  AUTORUN_DEPTH ;
extern int OldFocus;
extern INT8U zoomlevel;
extern INT8U  FileMenuToSingle;
extern INT8U filelist_show_flag ;
extern INT8U isMute ;
extern INT8U pic_panel_flag;
extern INT16U JpegPlayStatus ;
extern INT16U JpegPlayStatus ;
extern INT32S PicPlayStatus;
extern INT32U NODIR_FLAG;
extern INT32U cur_filetype_flag;
extern unsigned char Volume_Value;
extern unsigned char CurDriver[10] ;
extern char gCurOnlyFileName[256] ;
#if HOTKEYENABLE
extern char hotkey_flag ;
#endif
extern INT32U last_hotkey ;

static int aw_title_get = 0;
static int aw_title_pause;
static int aw_title_last_index = 0 ;
static AVTimer_t auto_scroll_timer = 0;
static AVTimer_t caption_moving_timer = 0;
static AVTimer_t PIC_caption_moving_timer_1=0;
static unsigned load_picapp_data[5];
static char device_removed=0;
static char pic_processing_status = PIC_STATUS_QUITTING;
static char *last_file_name;
static Playlist_t *pic_player_playlist;
static PlaylistItem_t *pic_player_playitem;

extern unsigned char PC_Connect;
#ifdef ENABLE_BLUETOOTH_OPP
extern int opp_copy_flag ;
#endif

void AWPICQuitProcess(void);
void send_pic_player_quit(void);
extern void UpdateSixPicFocus(PHWND hwnd,int pic_focus);
INT8U ShowSixPicFlag = 0 ; 
extern INT8U ComboPlayMP3_CurDriver(void);

extern struct tm * localtime(const time_t   *__timer);
#ifdef CHIP_7221
#pragma Data(LIT,".flash")
#endif
int pic_limitation[12] = {-1,-1,0x100000,0x100000,0x100000,0x100000,0x100000,0x100000,0x100000,0x100000,0x100000,0x100000};
unsigned char test_jpeg[]={
0xff,0xd8,0xff,0xe0,0,0x10,0x4a,0x46
,0x49,0x46,0,0x1,0x1,0x1,0,0x60
,0,0x60,0,0,0xff,0xdb,0,0x43
,0,0x8,0x6,0x6,0x7,0x6,0x5,0x8
,0x7,0x7,0x7,0x9,0x9,0x8,0xa,0xc
,0x14,0xd,0xc,0xb,0xb,0xc,0x19,0x12
,0x13,0xf,0x14,0x1d,0x1a,0x1f,0x1e,0x1d
,0x1a,0x1c,0x1c,0x20,0x24,0x2e,0x27,0x20
,0x22,0x2c,0x23,0x1c,0x1c,0x28,0x37,0x29
,0x2c,0x30,0x31,0x34,0x34,0x34,0x1f,0x27
,0x39,0x3d,0x38,0x32,0x3c,0x2e,0x33,0x34
,0x32,0xff,0xdb,0,0x43,0x1,0x9,0x9
,0x9,0xc,0xb,0xc,0x18,0xd,0xd,0x18
,0x32,0x21,0x1c,0x21,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0xff,0xc0
,0,0x11,0x8,0,0x42,0,0x7a,0x3
,0x1,0x22,0,0x2,0x11,0x1,0x3,0x11
,0x1,0xff,0xc4,0,0x1f,0,0,0x1
,0x5,0x1,0x1,0x1,0x1,0x1,0x1,0
,0,0,0,0,0,0,0,0x1
,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9
,0xa,0xb,0xff,0xc4,0,0xb5,0x10,0
,0x2,0x1,0x3,0x3,0x2,0x4,0x3,0x5
,0x5,0x4,0x4,0,0,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xf0,0xb8,0x3c,0x3f
,0xff,0,0x3e,0x7a,0x9f,0xfd,0xfa,0x8f
,0xff,0,0x8b,0xae,0x5b,0xc7,0x9e,0x3c
,0xd2,0xfc,0x51,0xa1,0xc1,0x65,0x65,0x5
,0xe4,0x72,0xc7,0x72,0xb3,0x13,0x3a,0x28
,0x18,0xa,0xc3,0xb3,0x1e,0x7e,0x61,0x5d
,0x58,0x3c,0x1d,0x78,0x57,0x8c,0xa5,0x16
,0x92,0x67,0x3e,0x2f,0x17,0x46,0x74,0x65
,0x18,0xcb,0x53,0x5e,0x8a,0x28,0xae,0xc3
,0xc6,0xa,0x28,0xa2,0x80,0xa,0x28,0xa2
,0x80,0xa,0x28,0xa2,0x80,0xa,0x28,0xa2
,0x80,0xa,0x28,0xa2,0x80,0xa,0x28,0xa2
,0x80,0xa,0x28,0xa2,0x80,0xa,0x28,0xa2
,0x80,0xa,0x28,0xa2,0x80,0x3f,0xff,0xd9
};

unsigned char test_jpeg_480[]={
0xff,0xd8,0xff,0xe0,0,0x10,0x4a,0x46
,0x49,0x46,0,0x1,0x1,0x1,0,0x60
,0,0x60,0,0,0xff,0xdb,0,0x43
,0,0x8,0x6,0x6,0x7,0x6,0x5,0x8
,0x7,0x7,0x7,0x9,0x9,0x8,0xa,0xc
,0x14,0xd,0xc,0xb,0xb,0xc,0x19,0x12
,0x13,0xf,0x14,0x1d,0x1a,0x1f,0x1e,0x1d
,0x1a,0x1c,0x1c,0x20,0x24,0x2e,0x27,0x20
,0x22,0x2c,0x23,0x1c,0x1c,0x28,0x37,0x29
,0x2c,0x30,0x31,0x34,0x34,0x34,0x1f,0x27
,0x39,0x3d,0x38,0x32,0x3c,0x2e,0x33,0x34
,0x32,0xff,0xdb,0,0x43,0x1,0x9,0x9
,0x9,0xc,0xb,0xc,0x18,0xd,0xd,0x18
,0x32,0x21,0x1c,0x21,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0x32,0x32
,0x32,0x32,0x32,0x32,0x32,0x32,0xff,0xc0
,0,0x11,0x8,0,0x56,0,0x66,0x3
,0x1,0x22,0,0x2,0x11,0x1,0x3,0x11
,0x1,0xff,0xc4,0,0x1f,0,0,0x1
,0x5,0x1,0x1,0x1,0x1,0x1,0x1,0
,0,0,0,0,0,0,0,0x1
,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9
,0xa,0xb,0xff,0xc4,0,0xb5,0x10,0
,0x2,0x1,0x3,0x3,0x2,0x4,0x3,0x5
,0x5,0x4,0x4,0,0,0x1,0x7d,0x1
,0x2,0x3,0,0x4,0x11,0x5,0x12,0x21
,0x31,0x41,0x6,0x13,0x51,0x61,0x7,0x22
,0x71,0x14,0x32,0x81,0x91,0xa1,0x8,0x23
,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24
,0x33,0x62,0x72,0x82,0x9,0xa,0x16,0x17
,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,0x29
,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a
,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a
,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a
,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a
,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a
,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99
,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8
,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7
,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6
,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5
,0xd6,0x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14,0x50,0x1,0x45,0x14
,0x50,0x1,0x45,0x14,0x50,0x1,0x45,0x14
,0x50,0x1,0x45,0x14,0x50,0x1,0x45,0x14
,0x50,0x7,0xff,0xd9};
#ifdef CHIP_7221
#pragma Data()
#endif
unsigned short GetSystermMode()
{
	int video_fd;
	unsigned short hdmode;
	video_appmode_t video_appmode;
	video_fd=open("/dev/video",O_RDONLY);
    ioctl(video_fd, VIDEOIO_GETAPPMODE, &video_appmode);
    close(video_fd);
    hdmode=video_appmode.hdmode;
    return hdmode;
}
static void caption_moving_time_func(void *arg)
{
    PHWND hwnd=(PHWND)arg;
    if(!AWIsVisibleWinControl(hwnd))
    	return ; 	
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+8);  	
    AVSysEvent_Post(gAppAgrs[gAWGUIAppID].app_event_handle) ; 
    
    
    return ;
}

static void PIC_caption_moving_time_func_1(void *arg)
{
    PHWND hwnd=(PHWND)arg;	
    if(!AWIsVisibleWinControl(hwnd))
    	return ; 
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 8);   	
    AVSysEvent_Post(gAppAgrs[gAWGUIAppID].app_event_handle) ; 
   
    
    return ;
}

static void PicInit()
{
    Music_Pic_mix_flag = 0 ;
    Pic_Decode_Percent = 0 ;
    aw_title_get = 0 ;
    aw_title_num = 0 ;
    aw_title_last_index = 0 ;
    JpegPlayStatus=1;	
   // UpdatePicPlayStatusControl(PIC_PLAY, -1) ;
//    UpdatePicutreResolution(0) ;
//    UpdateJpgZoomControl(0);
}

// if flag = 1 ,if in title mode need get 
// the current highlight item name.
char *PicGetCurrentPlayingName(INT8U flag)
{
//    PlaylistItem_t * pl;
    if((aw_title_mode) && (flag)) {
        AWGetNthPlaylistItem2(pic_player_playlist, aw_title_num) ;
        aw_title_get = 1 ;
    }
   /* pl=AWGetCurrentPlaylistItem2(pic_player_playlist);
    if(pl){
        return pl->location;   
    }    
    else
        return NULL;*/
        return CurDriver;
       
}

void PicReturnLastIndex()
{
    if(aw_title_mode) {
        AWGetNthPlaylistItem2(pic_player_playlist, aw_title_last_index) ;
        aw_title_get = 1 ;
    }
}

static INT8U preview_index=1;
static INT8U preview_max_num=0;
static char pic_thumbnail_name[128];



INT8U PicCmdResponse(AWMSG *pMsg, PCMDSET cmd_set)
{
    INT8U iRet = BREAK_EXECUTE_COMMAND ;

    switch(pMsg->msg_type){
        case MSG_COMMAND_SUCCESS:
            /*if (Music_Pic_mix_flag) {
                UpdateMusicPic_PicPlayFileName(AWGetCurrentPlaylistItem(MEDIA_PIC)) ;
            }
            else*/ {
            if(pic_playmode != 5)
                UpdatePicutrePlayFileName(AWGetCurrentPlaylistItem(MEDIA_PIC)) ;
//                if(cmd_set->commands[0] == CM_PLAY) {
//                    UpdatePicPlayStatusControl(PIC_PLAY, -1) ;
//                }
            }
            
            iRet = GO_ON_EXECUTE_COMMAND ;
            break ;
        case MSG_COMMAND_FAIL:
#ifdef ENABLE_NETWORK
			if(((cmd_set->commands[0] == CM_LOAD_APP) ||(cmd_set->commands[0] == CM_PLAY))&&(pic_playmode==5))
			{
				UpdatePreviewShow(preview_index,0);
				if(preview_index<preview_max_num)
				{
					PreviewNextFile();
				}
				else
				{
					quit_flag = 0xfe;
					send_pic_player_quit();
					AWPICQuitProcess();
				}
			}
#endif
            break ;
        case MSG_COMMAND_FORBIDEN:
            break ;
        case MSG_COMMAND_NOT_SUPPORT:
            iRet = GO_ON_EXECUTE_COMMAND ;
        default:
            break ;
    }
    return iRet ;
}


static void send_pic_player_quit(void)
{
    INT8U my_app_id ;
    INT16U pCmds = CM_QUIT;
    INT32U pCmdsParam = 0;
    INT8U pCmdTimeOut = 0;

    AWGetAppID(MEDIA_PIC, &my_app_id) ; 
    AWAddCmdSet(1, &pCmds, &pCmdsParam, &pCmdTimeOut, 
                my_app_id, PicCmdResponse) ;
}

/* Callback from the playlist module when the next
 * playlist item has been retrieved. */
static void PICPlaylistCb(Playlist_t *playlist, 
                              PlaylistItem_t *item,
                              PlaylistStatus_t status)
{
    PAPPTASKARG pPICAppArg;
    
    if(aw_title_get) {
        aw_title_get = 0 ;
        return ;
    }

    if(status == PLAYLIST_STATUS_OK) {
        if((GetAppType(item->location) == MEDIA_OTHER) ||
           (GetAppType(item->location) == MEDIA_NULL)){
            pPICAppArg = AWGetAppArg(MEDIA_PIC) ;	
            AWAppSendMessage(pPICAppArg->app_id, pPICAppArg->aw_msg_q,  pPICAppArg->aw_event_handle,
                             MSG_NOTIFICATION, NM_GET_NEXT, 0) ;
            return ;
        }
        if(GetAppType(item->location) != MEDIA_PIC) {
        	pic_processing_status = PIC_STATUS_SWITCHING;
        	send_pic_player_quit();
            pic_player_playlist = playlist;
            pic_player_playitem = item;
        }
        else {
            AWLockPlaylist(playlist);
            AWGUISendNMMessage(GetAppType(item->location), NM_PLAY_GENERAL, (INT32U)playlist) ;
        }
    }
    else if((status == PLAYLIST_STATUS_GET_NEXT) ||
            (status == PLAYLIST_STATUS_GET_PREV)){

            pPICAppArg = AWGetAppArg(MEDIA_PIC) ;	
            AWAppSendMessage(pPICAppArg->app_id, pPICAppArg->aw_msg_q,  pPICAppArg->aw_event_handle,
                             MSG_NOTIFICATION, ((status == PLAYLIST_STATUS_GET_NEXT) ? NM_GET_NEXT : NM_GET_PREV), 0) ;

            return ;
    }
    else {
        AWGUISendNMMessage(MEDIA_PIC, NM_PLAY_PIC, 0);
    }
}

void SetPicEffect(INT32S para)
{
      PCMDSET pCmd;//para value note:0:  NORMAL;1:  SHARPER;2:  SOFTER
	    pCmd = AWCommandSetMalloc() ;
    	pCmd->command_num = 1 ;
    	pCmd->curr_executed_cmd_num = 0 ;
    	pCmd->commands[0] = CM_SET_JPEG_SCALER_EFFECT;
    	pCmd->commands_para[0] = para;;	 
    	pCmd->cmd_timeout_value[0] = 2 ;
    	AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
    	pCmd->ExecuteResultProcess = PicCmdResponse ;
    	AWAddCommandSet(pCmd) ;

}


static void send_pic_player_file(char *file_name)
{
    PCMDSET pCmd ;

    pCmd = AWCommandSetMalloc();
    pCmd->command_num = 1;
    pCmd->curr_executed_cmd_num = 0;
    pCmd->commands[0] = CM_LOAD_APP;
    pCmd->commands_para[0] = (INT32U)load_picapp_data;
    AVSchedLock();
    load_picapp_data[0] = (unsigned)file_name;
    AVSchedUnlock();

    pCmd->cmd_timeout_value[0] = 5;
    AWGetAppID(MEDIA_PIC, &pCmd->app_id);
    pCmd->ExecuteResultProcess = PicCmdResponse;
    AWAddCommandSet(pCmd);
    
    last_file_name = file_name;
    aw_title_pause = 0;
}
static void send_pic_default_file()
{
    PCMDSET pCmd ;

    pCmd = AWCommandSetMalloc();
    pCmd->command_num = 1;
    pCmd->curr_executed_cmd_num = 0;
    pCmd->commands[0] = CM_LOAD_APP;
    pCmd->commands_para[0] = (INT32U)load_picapp_data;
    AVSchedLock();
    
    sprintf(data_src.magic,"%s","memory.jpg");
#ifdef TV_MODE_1080P
    if((GetSystermMode()==DISPCTL_MODE_1080P)||(GetSystermMode()==DISPCTL_MODE_1080I))
    {
    	data_src.data = (unsigned char*)test_jpeg;
    	data_src.len = sizeof(test_jpeg);
	}
	else
#endif
#ifdef TV_MODE_720P
    if(GetSystermMode()==DISPCTL_MODE_720P)
    {
    	data_src.data = (unsigned char*)test_jpeg;
    	data_src.len = sizeof(test_jpeg);
	}
	else
#endif
	{
		data_src.data = (unsigned char*)test_jpeg_480;
    	data_src.len = sizeof(test_jpeg_480);
    }
    load_picapp_data[0] = (unsigned)&data_src;
    AVSchedUnlock();
    pCmd->cmd_timeout_value[0] = 5;
    AWGetAppID(MEDIA_PIC, &pCmd->app_id);
    pCmd->ExecuteResultProcess = PicCmdResponse;
    AWAddCommandSet(pCmd);
    aw_title_pause = 0;
}

static void send_pic_player_file_title(void)
{
	PCMDSET pCmd ;

    	pCmd = AWCommandSetMalloc();
    	pCmd->command_num = 1;
    	pCmd->curr_executed_cmd_num = 0;
    	pCmd->commands[0] = CM_THUMBNAIL;
    	//pCmd->commands_para[0] = (INT32U)load_picapp_data;
    	//AVSchedLock();
    	//load_picapp_data[0] = (unsigned)file_name;
    	//AVSchedUnlock();

    	pCmd->cmd_timeout_value[0] = 2;
    	AWGetAppID(MEDIA_PIC, &pCmd->app_id);
    	pCmd->ExecuteResultProcess = PicCmdResponse;
    	AWAddCommandSet(pCmd);
    
    	//last_file_name = file_name;
    	//aw_title_pause = 0;
}
static void set_pic_par(unsigned char *logodata, unsigned logosize, unsigned flag)
{
    /*
     * Sample Code:
     * 1. Start PIC application
     *      How:
     *          AWGetAppID(MEDIA_PIC, &my_app_id);
     *          AWAppRunning(my_app_id);
     *    The PIC payback thread is running and waiting for CM_LOAD_APP command
     * 2. Send initial playback parameter to BMP
     *      How:
     *      The command type of CM_LOAD_APP:
     *      parameter[0]:   file name address
     *      parameter[1]:   bit [0], audio compatible flag
     *                      bit [1], page start flag
     *                      bit [2-], file index in play list
     *      parameter[2]:   logo data address
     *      parameter[3]:   logo data size
     *      parameter[4]:   user context, normally is application callback to
     *                      interrupt data reading operation
     *      Note:
     *      When PIC playback quits, the logo will be displayed on the screen
     * 3. Flag:
     *      bit 0: this file is the first file for title display mode
     *      bit 1: this file is a file in title display mode
     */

    INT8U audio_app_id;

    AVSchedLock();

    load_picapp_data[1] = 0;
    
    if (AWGetAppID(MEDIA_GENERAL, &audio_app_id) == 0) {
        if (AWGetAppStatus(audio_app_id) == APP_RUNNING) {
            load_picapp_data[1] |= PIC_PLAY_FLAG_AUDIO_COMP;   /* audio compatiable flag */
            Music_Pic_mix_flag = 1 ;
            SetPicEffect(2);
           /* if(Mp3NotInPlay()) {
                AWGPlayerKeyDo(UOP_END_PAUSE) ;
            }*/
        } else {
//        	load_picapp_data[1] &= PIC_PLAY_FLAG_AUDIO_COMP;   /* audio compatiable flag */            
            Music_Pic_mix_flag = 0 ;
            SetPicEffect(1);
        }
    }
    else {
        Music_Pic_mix_flag = 0 ;
    }
    
    aw_title_mode = (flag & 2)?1:0;
    if (flag & 1) {
        load_picapp_data[1] |= PIC_PLAY_FLAG_PAGE_START;
        aw_title_mode = 1;
    }
    
    load_picapp_data[2] = (unsigned)logodata;
    //load_picapp_data[3] = (unsigned)logosize;
    load_picapp_data[3] = (unsigned)0;
    if(!ShowSixPicFlag){
        pic_extra_info.Bk_Pic_Need_Clear = 1;
        load_picapp_data[4] = (unsigned)&pic_extra_info;
    }else{
        pic_extra_info.Bk_Pic_Need_Clear = 0;
        load_picapp_data[4] = (unsigned)&pic_extra_info;
    }

    AVSchedUnlock();
    
}    
int pic_slide_show_mode = -1 ;
int pic_title_mode = 12;
int pic_watch_dog = 0;
int pic_use_default_enable = 1; /*use  default jpeg display instead of error picture*/

unsigned user_window[5]={1,70,472,200,200};
unsigned multi_pic_window_576[61] = {0x000e0000,
                                106+5+48,72+1 ,108, 92,
                                106+5+48,188+1,108, 92,
                                106+5+48,304+1,108, 92,
                                106+5+48,420+1,108, 92,
                                106+5+48,536+1,108, 92,

                                206+5+48,72+1, 108, 92,
                                206+5+48,188+1,108, 92,
                                206+5+48,304+1,108, 92,
                                206+5+48,420+1,108, 92,
                                206+5+48,536+1,108, 92,
                                
                                306+5+48,72+1, 108, 92,
                                306+5+48,188+1,108, 92,
                                306+5+48,304+1,108, 92,
                                306+5+48,420+1,108, 92,
                                306+5+48,536+1,108, 92,
                                }; 
unsigned multi_pic_window[61] = {0x000e0000,
                                106+5,72+1 ,108, 92,
                                106+5,188+1,108, 92,
                                106+5,304+1,108, 92,
                                106+5,420+1,108, 92,
                                106+5,536+1,108, 92,

                                206+5,72+1, 108, 92,
                                206+5,188+1,108, 92,
                                206+5,304+1,108, 92,
                                206+5,420+1,108, 92,
                                206+5,536+1,108, 92,
                                
                                306+5,72+1, 108, 92,
                                306+5,188+1,108, 92,
                                306+5,304+1,108, 92,
                                306+5,420+1,108, 92,
                                306+5,536+1,108, 92,
                                }; 
#ifdef SUPPORT_VGA
unsigned multi_pic_window_vga[61] = {0x000e0000,
                                106+5+WinStart_y,72+1+WinStart_x ,108, 92,
                                106+5+WinStart_y,188+1+WinStart_x,108, 92,
                                106+5+WinStart_y,304+1+WinStart_x,108, 92,
                                106+5+WinStart_y,420+1+WinStart_x,108, 92,
                                106+5+WinStart_y,536+1+WinStart_x,108, 92,

                                206+5+WinStart_y,72+1+WinStart_x, 108, 92,
                                206+5+WinStart_y,188+1+WinStart_x,108, 92,
                                206+5+WinStart_y,304+1+WinStart_x,108, 92,
                                206+5+WinStart_y,420+1+WinStart_x,108, 92,
                                206+5+WinStart_y,536+1+WinStart_x,108, 92,
                                
                                306+5+WinStart_y,72+1+WinStart_x, 108, 92,
                                306+5+WinStart_y,188+1+WinStart_x,108, 92,
                                306+5+WinStart_y,304+1+WinStart_x,108, 92,
                                306+5+WinStart_y,420+1+WinStart_x,108, 92,
                                306+5+WinStart_y,536+1+WinStart_x,108, 92,
                                };
#endif

#ifdef TV_MODE_720P
unsigned multi_pic_window_720P[193] = {0x002f0000,
                                144+2,80 ,132, 76,
                                144+2,220,132, 76,
                                144+2,360,132, 76,
                                144+2,500,132, 76,
                                144+2,640,132, 76,
                                144+2,780,132, 76,
                                144+2,920,132, 76,
                                144+2,1060,132,76,

                                224+2,80 ,132, 76,
                                224+2,220,132, 76,
                                224+2,360,132, 76,
                                224+2,500,132, 76,
                                224+2,640,132, 76,
                                224+2,780,132, 76,
                                224+2,920,132, 76,
                                224+2,1060,132,76,
                                
                                304+2,80 ,132, 76,
                                304+2,220,132, 76,
                                304+2,360,132, 76,
                                304+2,500,132, 76,
                                304+2,640,132, 76,
                                304+2,780,132, 76,
                                304+2,920,132, 76,
                                304+2,1060,132,76,
                                
                                384+2,80 ,132, 76,
                                384+2,220,132, 76,
                                384+2,360,132, 76,
                                384+2,500,132, 76,
                                384+2,640,132, 76,
                                384+2,780,132, 76,
                                384+2,920,132, 76,
                                384+2,1060,132,76,
                                
                                464+2,80 ,132, 76,
                                464+2,220,132, 76,
                                464+2,360,132, 76,
                                464+2,500,132, 76,
                                464+2,640,132, 76,
                                464+2,780,132, 76,
                                464+2,920,132, 76,
                                464+2,1060,132,76,
                                 
                                
                                544+2,80 ,132, 76,
                                544+2,220,132, 76,
                                544+2,360,132, 76,
                                544+2,500,132, 76,
                                544+2,640,132, 76,
                                544+2,780,132, 76,
                                544+2,920,132, 76,
                                544+2,1060,132,76,
                                
                                }; 
#endif

#ifdef TV_MODE_1080P
unsigned multi_pic_window_1080P[193] = {0x002F0000,
	180+2,80+50+2,176,118-2,
	180+2,290+50+2,176,118-2,
	180+2,500+50+2,176,118-2,
	180+2,710+50+2,176,118-2,
	180+2,920+50+2,176,118-2,
	180+2,1130+50+2,176,118-2,
	180+2,1340+50+2,176,118-2,
	180+2,1550+50+2,176,118-2,
	
	310+2,80+50+2,176,118-2,
	310+2,290+50+2,176,118-2,
	310+2,500+50+2,176,118-2,
	310+2,710+50+2,176,118-2,
	310+2,920+50+2,176,118-2,
	310+2,1130+50+2,176,118-2,
	310+2,1340+50+2,176,118-2,
	310+2,1550+50+2,176,118-2,

	
	
	440+2,80+50+2,176,118-2,
	440+2,290+50+2,176,118-2,
	440+2,500+50+2,176,118-2,
	440+2,710+50+2,176,118-2,
	440+2,920+50+2,176,118-2,
	440+2,1130+50+2,176,118-2,
	440+2,1340+50+2,176,118-2,
	440+2,1550+50+2,176,118-2,


                                
	570+2,80+50+2,176,118-2,
	570+2,290+50+2,176,118-2,
	570+2,500+50+2,176,118-2,
	570+2,710+50+2,176,118-2,
	570+2,920+50+2,176,118-2,
	570+2,1130+50+2,176,118-2,
	570+2,1340+50+2,176,118-2,
	570+2,1550+50+2,176,118-2,
                                
                                
                                 
	700+2,80+50+2,176,118-2,
	700+2,290+50+2,176,118-2,
	700+2,500+50+2,176,118-2,
	700+2,710+50+2,176,118-2,
	700+2,920+50+2,176,118-2,
	700+2,1130+50+2,176,118-2,
	700+2,1340+50+2,176,118-2,
	700+2,1550+50+2,176,118-2,
                                
                                
	830+2,80+50+2,176,118-2,
	830+2,290+50+2,176,118-2,
	830+2,500+50+2,176,118-2,
	830+2,710+50+2,176,118-2,
	830+2,920+50+2,176,118-2,
	830+2,1130+50+2,176,118-2,
	830+2,1340+50+2,176,118-2,
	830+2,1550+50+2,176,118-2,
                                }; 
#endif
#ifdef ENABLE_NETWORK

extern INT8U enable_playstatus;
extern char *GetFileItemName(INT8U File_offset,INT8U max_num);
//extern void UpdatePreviewShow(INT8U item_index,INT8U preview_flag);

INT8U PicSysSetting_DefineMode_Preview(void)
{
	PCMDSET pCmd4;
	INT8U ret;
	/*set the user define window*/
	pCmd4 = AWCommandSetMalloc() ;
	pCmd4->command_num = 1 ;
	pCmd4->curr_executed_cmd_num = 0 ;
	pCmd4->commands[0] = CM_SET_USER_DEFINE_WINDOW;
	pCmd4->commands_para[0] = (unsigned)user_window ;
	pCmd4->cmd_timeout_value[0] = 2 ;
	AWGetAppID(MEDIA_PIC, &pCmd4->app_id) ;
	pCmd4->ExecuteResultProcess = PicCmdResponse ;
	ret = AWAddCommandSet(pCmd4) ;
	return ret;
}

void SetUser_Windows_Para(INT8U preview_id)
{
	user_window[0]=5;
	user_window[1]=multi_pic_window[(preview_id-1)*4 +1];//top
	user_window[2]=multi_pic_window[(preview_id-1)*4 +2];//top
	user_window[3]=multi_pic_window[(preview_id-1)*4 +3];//top
	user_window[4]=multi_pic_window[(preview_id-1)*4 +4];//top
}

int PreviewPicPlayer(INT8U max_preview_num)
{
	int r = 0;
	INT8U my_app_id ;
	char *temp = NULL;
	char *dev_str = NULL;
	preview_max_num=max_preview_num;
	preview_index=1;
	if(preview_max_num<preview_index)
	{
		return -1;
	}
	pic_playmode = 5;	
	temp=GetFileItemName(preview_index,max_preview_num);
	if(!temp)
		return -1;
	dev_str = FileNavGetDeviceTypeStr(FileNavGetCurrDir());
	if(!dev_str)
		return -1;
	if(Is_Gallery(dev_str))    
	{
		int ii=strlen(temp);
		if(ii<128)
		{
			memcpy(pic_thumbnail_name,temp,ii+1);
			temp=pic_thumbnail_name;   
			ii--;
			while(temp[ii]!='.')
			{
				ii--;   
			}    
			temp[ii+1]='t';
			temp[ii+2]='h';
			temp[ii+3]='u';
			temp[ii+4]=0;
		}    
	}    
	if((temp)&&(temp[0]!=0))
	{
		AWGetAppID(MEDIA_PIC, &my_app_id) ; 
		if (AWGetAppStatus(my_app_id) != APP_RUNNING) 
		{
			AWAppRunning(my_app_id) ;
			pic_processing_status = PIC_STATUS_RUNNING;            
		}	
		SetUser_Windows_Para(preview_index);
		PicSysSetting_DefineMode_Preview();
		send_pic_player_file(temp);		
	}
	else
		return -1;
	return r;	
}

int PreviewNextFile(void)
{
	int r = 0;
	INT8U my_app_id ;
	char *temp = NULL;
	char *dev_str = NULL;
	pic_playmode = 5;	
	preview_index++;
	AWGetAppID(MEDIA_PIC, &my_app_id) ; 
	if (AWGetAppStatus(my_app_id) != APP_RUNNING) 
	{
		AWAppRunning(my_app_id) ;
		pic_processing_status = PIC_STATUS_RUNNING;            
	}
	temp=GetFileItemName(preview_index,preview_max_num);
	if(!temp)
		return -1;
	dev_str = FileNavGetDeviceTypeStr(FileNavGetCurrDir());
	if(!dev_str)
		return -1;
	if(Is_Gallery(dev_str))    
	{
		int ii=strlen(temp);
		if(ii<128)
		{
			memcpy(pic_thumbnail_name,temp,ii+1);
			temp=pic_thumbnail_name;   
			ii--;
			while(temp[ii]!='.')
			{
			ii--;   
			}    
			temp[ii+1]='t';
			temp[ii+2]='h';
			temp[ii+3]='u';
			temp[ii+4]=0;
		}    
	}    
	if((temp)&&(temp[0]!=0))
	{
		SetUser_Windows_Para(preview_index);
		PicSysSetting_DefineMode_Preview();
		send_pic_player_file(temp);		
	}
	else
		return -1;
	return r;	
}
#endif

void SetPicWinNum()
{
#ifdef TV_MODE_1080P
    if((GetSystermMode()==DISPCTL_MODE_1080P)||(GetSystermMode()==DISPCTL_MODE_1080I))
    {
        SHOW_WINDOW_NUM=48;
        SIXPIC_ROW_TOTAL=8;
        SIXPIC_LINE_TOTAL=6;
	}
	else
#endif
#ifdef TV_MODE_720P
    if(GetSystermMode()==DISPCTL_MODE_720P)
    {
        SHOW_WINDOW_NUM=48;
        SIXPIC_ROW_TOTAL=8;
        SIXPIC_LINE_TOTAL=6;
	}
	else
#endif
    {
        SHOW_WINDOW_NUM= 15;
        SIXPIC_ROW_TOTAL =  5;
        SIXPIC_LINE_TOTAL=  3 ;
    }
}

unsigned transition_config[4]= {0x1f0f ,0,0,0};


void PicSysSetting()
{
/*set the slide show mode*/	
	set_title_indicator_enable(0);
    PCMDSET pCmd,pCmd1,pCmd2,pCmd3,pCmd4,pCmd6,pCmd7,pCmd13,pCmd0;
    pCmd = AWCommandSetMalloc() ;
    pCmd->command_num = 1 ;
    pCmd->curr_executed_cmd_num = 0 ;
    pCmd->commands[0] = CM_SET_PIC_TRANSITION_CONFIG;
    pCmd->commands_para[0] = (unsigned)transition_config ;		
   	pCmd->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
    pCmd->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd) ; 
	 pCmd0 = AWCommandSetMalloc() ;
    pCmd0->command_num = 1 ;
    pCmd0->curr_executed_cmd_num = 0 ;
    pCmd0->commands[0] = CM_SMALL_PIC_DISPLAY_POLICY;
    pCmd0->commands_para[0] = (unsigned)0 ;		
   	pCmd0->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd0->app_id) ;
    pCmd0->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd0) ; 
	
    pCmd1 = AWCommandSetMalloc() ;
    pCmd1->command_num = 1 ;
    pCmd1->curr_executed_cmd_num = 0 ;
    pCmd1->commands[0] = CM_SET_PIC_SHOW_MODE;
    pCmd1->commands_para[0] = pic_slide_show_mode ;
    pCmd1->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd1->app_id) ;
    pCmd1->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd1) ;
/*set the title display mode*/    
    pCmd2 = AWCommandSetMalloc() ;
    pCmd2->command_num = 1 ;
    pCmd2->curr_executed_cmd_num = 0 ;
    pCmd2->commands[0] = CM_SET_PIC_TITLE_MODE;
    pCmd2->commands_para[0] = SHOW_WINDOW_NUM ;
    pCmd2->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd2->app_id) ;
    pCmd2->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd2) ;
/*set the pic switch watchdog*/ 
    pCmd3 = AWCommandSetMalloc() ;
    pCmd3->command_num = 1 ;
    pCmd3->curr_executed_cmd_num = 0 ;
    pCmd3->commands[0] = CM_SET_PIC_WATCH_DOG;
#ifdef DEMO_SHOW_VPP_EFFECT_SRC_WINDOW
	if(pic_slide_show_mode == SHOW_VPP_EFFECT_SRC_WINDOW)
        pCmd3->commands_para[0] = 6 ;   //30 seconds
#else
    pCmd3->commands_para[0] = pic_watch_dog ;
#endif
    pCmd3->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd3->app_id) ;
    pCmd3->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd3) ;
/*set the user define window*/ 
	pCmd4 = AWCommandSetMalloc() ;
	pCmd4->command_num = 1 ;
	pCmd4->curr_executed_cmd_num = 0 ;
	pCmd4->commands[0] = CM_SET_USER_DEFINE_WINDOW;
    if(ShowSixPicFlag){
    #ifdef TV_MODE_1080P
        if((GetSystermMode()==DISPCTL_MODE_1080P)||(GetSystermMode()==DISPCTL_MODE_1080I))
            pCmd4->commands_para[0] = (unsigned)multi_pic_window_1080P ;	
        else
    #endif
    #ifdef TV_MODE_720P
        if((GetSystermMode()==DISPCTL_MODE_720P))
    		pCmd4->commands_para[0] = (unsigned)multi_pic_window_720P ;	
        else
    #endif
    	 if((GetSystermMode()==DISPCTL_MODE_576I)||(GetSystermMode()==DISPCTL_MODE_576P))   		
		pCmd4->commands_para[0] = (unsigned)multi_pic_window_576 ;
#ifdef SUPPORT_VGA
	else if(GetSystermMode()==DISPCTL_MODE_VGA)
		pCmd4->commands_para[0] = (unsigned)multi_pic_window_vga ;
#endif
	else
		pCmd4->commands_para[0] = (unsigned)multi_pic_window ;	
	}
//    pCmd4->commands_para[0] = (unsigned)user_window ;
    else
    pCmd4->commands_para[0] = (unsigned)user_window ;
	pCmd4->cmd_timeout_value[0] = 2 ;
	AWGetAppID(MEDIA_PIC, &pCmd4->app_id) ;
	pCmd4->ExecuteResultProcess = PicCmdResponse ;
	AWAddCommandSet(pCmd4) ;
	   /*enable default jpeg display instead of error picture*/	
    	pCmd7 = AWCommandSetMalloc() ;
    	pCmd7->command_num = 1 ;
    	pCmd7->curr_executed_cmd_num = 0 ;
    	pCmd7->commands[0] = CM_SET_PIC_USE_DEFAULT_ENABLE;
    	pCmd7->commands_para[0] = pic_use_default_enable ;		
    	pCmd7->cmd_timeout_value[0] = 2 ;
    	AWGetAppID(MEDIA_PIC, &pCmd7->app_id) ;
    	pCmd7->ExecuteResultProcess = PicCmdResponse ;
    	AWAddCommandSet(pCmd7) ;   
  if(1)
    {
    /*set the title show auto mode*/	
        pCmd6 = AWCommandSetMalloc() ;
        pCmd6->command_num = 1 ;
        pCmd6->curr_executed_cmd_num = 0 ;
        pCmd6->commands[0] = CM_SET_PIC_PLAY_MODE;
        if(ShowSixPicFlag)
            pCmd6->commands_para[0] = 1 ;   //0 for normal, 1 for auto 6 pics
        else
            pCmd6->commands_para[0] = 0 ;   //0 for normal, 1 for auto 6 pics
        pCmd6->cmd_timeout_value[0] = 2 ;
        AWGetAppID(MEDIA_PIC, &pCmd6->app_id) ;
        pCmd6->ExecuteResultProcess = PicCmdResponse ;
        AWAddCommandSet(pCmd6) ;
        

        pCmd13 = AWCommandSetMalloc() ;
        pCmd13->command_num = 1 ;
        pCmd13->curr_executed_cmd_num = 0 ;
        pCmd13->commands[0] = CM_SET_PIC_TITLE_REQUEST_INFO;
        if(ShowSixPicFlag)
            pCmd13->commands_para[0] = (INT32U)&six_pic_focus ;   //0 for normal, 1 for auto 6 pics
        else
            pCmd13->commands_para[0] = 0 ;   //0 for normal, 1 for auto 6 pics
        pCmd13->cmd_timeout_value[0] = 2 ;
        AWGetAppID(MEDIA_PIC, &pCmd13->app_id) ;
        pCmd13->ExecuteResultProcess = PicCmdResponse ;
        AWAddCommandSet(pCmd13) ;
        
    }
}
//extern char autorun_ShowSixPicFlag;
#ifdef ENABLE_BLUETOOTH
void BT_PicSysSetting()
{
/*set the slide show mode*/	
	set_title_indicator_enable(0);
    PCMDSET pCmd,pCmd1,pCmd2,pCmd3,pCmd4,pCmd6,pCmd7,pCmd13,pCmd0;
    pCmd = AWCommandSetMalloc() ;
    pCmd->command_num = 1 ;
    pCmd->curr_executed_cmd_num = 0 ;
    pCmd->commands[0] = CM_SET_PIC_TRANSITION_CONFIG;
    pCmd->commands_para[0] = (unsigned)transition_config ;		
   	pCmd->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
    pCmd->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd) ; 
	 pCmd0 = AWCommandSetMalloc() ;
    pCmd0->command_num = 1 ;
    pCmd0->curr_executed_cmd_num = 0 ;
    pCmd0->commands[0] = CM_SMALL_PIC_DISPLAY_POLICY;
    pCmd0->commands_para[0] = (unsigned)0 ;		
   	pCmd0->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd0->app_id) ;
    pCmd0->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd0) ; 

    pCmd1 = AWCommandSetMalloc() ;
    pCmd1->command_num = 1 ;
    pCmd1->curr_executed_cmd_num = 0 ;
    pCmd1->commands[0] = CM_SET_PIC_SHOW_MODE;
    pCmd1->commands_para[0] = -1;   //pic_slide_show_mode ;
    pCmd1->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd1->app_id) ;
    pCmd1->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd1) ;
/*set the title display mode*/    

    pCmd2 = AWCommandSetMalloc() ;
    pCmd2->command_num = 1 ;
    pCmd2->curr_executed_cmd_num = 0 ;
    pCmd2->commands[0] = CM_SET_PIC_TITLE_MODE;
    pCmd2->commands_para[0] = SHOW_WINDOW_NUM ;
    pCmd2->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd2->app_id) ;
    pCmd2->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd2) ;
/*set the pic switch watchdog*/ 
    pCmd3 = AWCommandSetMalloc() ;
    pCmd3->command_num = 1 ;
    pCmd3->curr_executed_cmd_num = 0 ;
    pCmd3->commands[0] = CM_SET_PIC_WATCH_DOG;
    pCmd3->commands_para[0] = 3;    //pic_watch_dog ; no limited
    pCmd3->cmd_timeout_value[0] = 2 ;
    AWGetAppID(MEDIA_PIC, &pCmd3->app_id) ;
    pCmd3->ExecuteResultProcess = PicCmdResponse ;
    AWAddCommandSet(pCmd3) ;
/*set the user define window*/ 
	pCmd4 = AWCommandSetMalloc() ;
	pCmd4->command_num = 1 ;
	pCmd4->curr_executed_cmd_num = 0 ;
	pCmd4->commands[0] = CM_SET_USER_DEFINE_WINDOW;
    if(ShowSixPicFlag){
    #ifdef TV_MODE_1080P
        if((GetSystermMode()==DISPCTL_MODE_1080P)||(GetSystermMode()==DISPCTL_MODE_1080I))
            pCmd4->commands_para[0] = (unsigned)multi_pic_window_1080P ;	
        else
    #endif
    #ifdef TV_MODE_720P
        if((GetSystermMode()==DISPCTL_MODE_720P))
    		pCmd4->commands_para[0] = (unsigned)multi_pic_window_720P ;	
        else
    #endif
    	 if((GetSystermMode()==DISPCTL_MODE_576I)||(GetSystermMode()==DISPCTL_MODE_576P))   		
		pCmd4->commands_para[0] = (unsigned)multi_pic_window_576 ;
#ifdef SUPPORT_VGA
	else if(GetSystermMode()==DISPCTL_MODE_VGA)
		pCmd4->commands_para[0] = (unsigned)multi_pic_window_vga ;
#endif
	else
		pCmd4->commands_para[0] = (unsigned)multi_pic_window ;	
	}
//    pCmd4->commands_para[0] = (unsigned)user_window ;
    else
    pCmd4->commands_para[0] = (unsigned)user_window ;
	pCmd4->cmd_timeout_value[0] = 2 ;
	AWGetAppID(MEDIA_PIC, &pCmd4->app_id) ;
	pCmd4->ExecuteResultProcess = PicCmdResponse ;
	AWAddCommandSet(pCmd4) ;
	   /*enable default jpeg display instead of error picture*/	
    	pCmd7 = AWCommandSetMalloc() ;
    	pCmd7->command_num = 1 ;
    	pCmd7->curr_executed_cmd_num = 0 ;
    	pCmd7->commands[0] = CM_SET_PIC_USE_DEFAULT_ENABLE;
    	pCmd7->commands_para[0] = pic_use_default_enable ;		
    	pCmd7->cmd_timeout_value[0] = 2 ;
    	AWGetAppID(MEDIA_PIC, &pCmd7->app_id) ;
    	pCmd7->ExecuteResultProcess = PicCmdResponse ;
    	AWAddCommandSet(pCmd7) ;   

  if(1)
    {
    /*set the title show auto mode*/	
        pCmd6 = AWCommandSetMalloc() ;
        pCmd6->command_num = 1 ;
        pCmd6->curr_executed_cmd_num = 0 ;
        pCmd6->commands[0] = CM_SET_PIC_PLAY_MODE;
        if(ShowSixPicFlag)
            pCmd6->commands_para[0] = 1 ;   //0 for normal, 1 for auto 6 pics
        else
            pCmd6->commands_para[0] = 0 ;   //0 for normal, 1 for auto 6 pics
        pCmd6->cmd_timeout_value[0] = 2 ;
        AWGetAppID(MEDIA_PIC, &pCmd6->app_id) ;
        pCmd6->ExecuteResultProcess = PicCmdResponse ;
        AWAddCommandSet(pCmd6) ;
        

        pCmd13 = AWCommandSetMalloc() ;
        pCmd13->command_num = 1 ;
        pCmd13->curr_executed_cmd_num = 0 ;
        pCmd13->commands[0] = CM_SET_PIC_TITLE_REQUEST_INFO;
        if(ShowSixPicFlag)
            pCmd13->commands_para[0] = (INT32U)&six_pic_focus ;   //0 for normal, 1 for auto 6 pics
        else
            pCmd13->commands_para[0] = 0 ;   //0 for normal, 1 for auto 6 pics
        pCmd13->cmd_timeout_value[0] = 2 ;
        AWGetAppID(MEDIA_PIC, &pCmd13->app_id) ;
        pCmd13->ExecuteResultProcess = PicCmdResponse ;
        AWAddCommandSet(pCmd13) ;
        
    }
}

#endif
int
RunPICPlayer(Playlist_t *playlist,unsigned char *logodata, unsigned logosize, unsigned flag)
{
    int r = 0;
    INT8U my_app_id ;
#if 0
    if(pic_player_playlist) {
        if(AWPlaylistDelete2(pic_player_playlist) == 0) {
            pic_player_playlist = NULL;
        }
    }
#endif    
    PicDefineMode_flag=0; 
    user_window[0]=0;
    pic_playmode = 0 ;
    PicInit() ;
    SetPicWinNum();
    AWGetAppID(MEDIA_PIC, &my_app_id) ; 
	//if(autorun_ShowSixPicFlag)
	//	ShowSixPicFlag = 0; 
    if (AWGetAppStatus(my_app_id) != APP_RUNNING) {
        AWAppRunning(my_app_id) ;
        pic_processing_status = PIC_STATUS_RUNNING;
        PicSysSetting();
    } else {
        AWPICKeyDo(UOP_STOP) ;

        return -1;
    }

    AWSetPlaylistAppCb(playlist, PICPlaylistCb);
    
    set_pic_par(logodata,logosize,flag);

    if(AWGetStartPlaylistItem2(playlist) == PLAYLIST_STATUS_ASYNCH) {
        pic_player_playlist = playlist;

        AWGetAppID(MEDIA_GENERAL, &my_app_id) ; 
        if (AWGetAppStatus(my_app_id) == APP_RUNNING) {

extern int SWITCH_MP3_PICINFO_FLAG;			  
                  SWITCH_MP3_PICINFO_FLAG=0;
        }
        else {
        }
        //UpdatePicPlayStatusControl(0, 0) ;
       
    } else {
        r = -1;
    }
    if(MultiMenuToSingle==3){
    	//if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    	if(!ShowSixPicFlag)
    	ShowWinPicInfoBar();
    	MultiMenuToSingle=0;
	}
    return r;
}


static void aw_pic_uop_nextchap()
{
    aw_title_pause = 0;
    pic_processing_status = PIC_STATUS_SKIPPING;
}

static void aw_pic_uop_prevchap()
{
    aw_title_pause = 0;
    pic_processing_status = PIC_STATUS_SKIPPING;
}

static void aw_pic_uop_endpause()
{
    aw_title_pause = 0;
}

static struct uop_op_s {
    unsigned    uop;
    unsigned    cmd;
    unsigned    timeout;
    void      (*func)(void);
} uop_op[] = {
    {UOP_RESUME,        CM_QUIT, 2, NULL},  /* need use CM_QUIT because CM_STOP will not make "pic task" quit */
    {UOP_STOP,          CM_QUIT, 2, NULL},  /* need use CM_QUIT because CM_STOP will not make "pic task" quit */
    {UOP_ZOOM,          CM_ZOOM_CHANGE, 2, NULL},
//	{UOP_ZOOM,          CM_SET_PIC_SHOW_MODE, 2, NULL},
    {UOP_ANGLE,         CM_ANGLE_CHANGE, 2, NULL},
    {UOP_LEFT,          CM_KEY_LEFT, 2, NULL},
    {UOP_RIGHT,         CM_KEY_RIGHT, 2, NULL},
    {UOP_UP,            CM_KEY_UP, 2, NULL},
    {UOP_DOWN,          CM_KEY_DOWN, 2, NULL},
   // {UOP_TITLE,         CM_THUMBNAIL, 2, NULL},
    {UOP_NEXT_CHAP,     CM_FRAME_PLUS, 2, aw_pic_uop_nextchap},
    {UOP_PREVIOUS_CHAP, CM_FRAME_MINUS, 2, aw_pic_uop_prevchap},
    {UOP_ENTER,         CM_PLAY, 2, NULL},
    {UOP_PAUSE,         CM_PAUSE, 2, NULL},
    {UOP_END_PAUSE,     CM_PLAY, 2, aw_pic_uop_endpause}
};
#define PIC_UOP_NUM (sizeof(uop_op)/ sizeof(struct uop_op_s))
char UnMount=0;
void AWPICQuitProcess(void)
{
	int current_index =0;
	int page_unit = 0 ;
	
	zoomlevel=0;
	rotatelevel=0;
	pic_processing_status = PIC_STATUS_QUITTING;

	/*stop when single picture mode,should return to the page where the playing file exist in*/   
	if(quit_flag == 0xfe)
	{
		if(pic_player_playlist) 
		{
			if(AWPlaylistDelete2(pic_player_playlist) == 0) 
			{
				pic_player_playlist = NULL;
			}
		}
		aw_title_mode=0;
		return;
	}
	quit_flag = 0;
	six_pic_focus.request_type  = ASSIGNED_PAGE;
	if((!UnMount)&&!uop_home_flag&&(pic_player_playlist) 
		&&((!filelist_show_flag)&&(!ShowSixPicFlag)))
	{
		current_index = AWGetCurrentPlaylistIndex(pic_player_playlist);
		page_unit= SIXPIC_LINE_TOTAL*SIXPIC_ROW_TOTAL;    /*15 pic*/
		six_pic_focus.request_index  = (current_index/page_unit)*page_unit;
		six_pic_focus.request_focus  = current_index%page_unit;        
	}
	else
	{
		six_pic_focus.request_focus = 0;
		six_pic_focus.request_index = 0;    
	}
	if(pic_player_playlist)
	{
		if((!filelist_show_flag)&&(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName("Win15Pic"))))
		{
			if(UnMount)
			{
				if(AWPlaylistDelete2(pic_player_playlist) == 0) 
					pic_player_playlist = NULL;
			}
	            if(uop_home_flag){
	            	if(AWPlaylistDelete2(pic_player_playlist) == 0) 
	            	pic_player_playlist = NULL;
	            	
	            }
			/*keep the pic_player_playlist*/
		}
		else
		{
			if(AWPlaylistDelete2(pic_player_playlist) == 0) 
			{
				pic_player_playlist = NULL;
			}
		}
	}
	if(device_removed)
	{
		device_removed=0;
		return;
	}
	aw_title_mode=0;
	//clear_current_screen();   //Fix bug 18087
}
extern char autorun_pic_flag;
extern int uop_resume_15pic;
extern unsigned char user_power_flag;
extern char force_display_logo;
void AWPICQuitProcess2(AWMSG *pMsg)
{
	Music_Pic_mix_flag = 0 ;
	#ifdef ENABLE_NETWORK
	enable_playstatus = 0;
	#endif
	if(quit_flag == 0xfe)
	{
		quit_flag = 0;
		return;
	}
	quit_flag = 0;
	if(device_removed)
	{
		device_removed=0;
		return ;
	}
    audio=0;  
    if(user_power_flag)
    	return;

#if HOTKEYENABLE	
	if(hotkey_flag){
		ReloadLogo();
		APPHotKeyProcess(&last_hotkey);
		hotkey_flag = 0 ;
		return ;
	}
#endif

	if(pic_processing_status == PIC_STATUS_SWITCHING) 
	{
		AWLockPlaylist(pic_player_playlist);
		AWGUISendNMMessage(GetAppType(pic_player_playitem->location), NM_PLAY_GENERAL, (INT32U)pic_player_playlist) ;
		pic_player_playlist = NULL;
		return;
	}
	if(caption_moving_timer)
	{
		AVTimerDelete(caption_moving_timer);
		caption_moving_timer= 0;
	}
    if(PIC_caption_moving_timer_1){
    	AVTimerDelete(PIC_caption_moving_timer_1);
	PIC_caption_moving_timer_1= 0;
    }
	DeleteTimer();
	if(auto_scroll_timer)
	{
		AVTimerDelete(auto_scroll_timer);
		auto_scroll_timer= 0;
	}

	if(UnMount!=1)
	{
		if (GetForceCloseMediaApp())
			return;
	}
#ifdef ENABLE_NETWORK
	PHWND dir_hwnd = AWGetFileList();
	PHWND win_hwnd = AWFindWinCtrlByName("Win15Pic_net");
	if((dir_hwnd) && (win_hwnd))
	{
		if(AWGetTopWindow(dir_hwnd) == win_hwnd)
		{
			ReloadLogoType(0) ;
			GUIShowWindow("Win15Pic_net");
			return;
		}
	}
#endif

#ifdef ENABLE_BLUETOOTH
    if(Quit_flag)
#endif
    	{
	if(uop_home_flag)
	{
		if(ShowSixPicFlag)
		GUIHideWindow(Win15Pic);	
		ReloadLogo();
		FileNavCD(CurDriver);
		GUIShowWindow(WinDeviceSelect);
		uop_home_flag=0;
	}
	else
	{
		if(!UnMount)
		{
			if(filelist_show_flag)
			{
				force_display_logo = 1;
				ReloadLogo();        
				AWShowFileList(1);
				// add by lqy
			}
			else
			{
				if (!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
				{
					//set_current_logo_type(1);
					force_display_logo = 1;
					ReloadLogo();   
		        #ifdef ENABLE_BLUETOOTH
                	if(bt_pic_flag)
                	{
        	    		GUIHideWindow(WinPicInfoBar);
        	    		CleanMiniBar();
                		GUIShowWindow(WinDeviceSelect);
                		bt_play_flag = 0;
						bt_pic_flag = 0;
                    }
                    else
                #endif
					GUIShowWindow(Win15Pic);
				}
				else
				{   
#ifdef ENABLE_BLUETOOTH
						if((!autorun_pic_flag)&&(!bt_play_flag))
#else
						if(!autorun_pic_flag)
#endif
							if(!uop_resume_15pic)
							{
								GUIHideWindow(Win15Pic);
								ReloadLogo() ;
								GUIShowWindow(WinFileTypeSelect);
							}
							else
							{
								GUIHideWindow(Win15Pic);
								ReloadLogo() ;
								cur_filetype_flag=2;
								GUIShowWindow(WinFileTypeSelect);
								uop_resume_15pic=0;
				           	 	}
				}
			}
		}
		else
		{
			ReloadLogo() ;
			GUIShowWindow(WinDeviceSelect);
			UnMount=0;
		}
			
	}   
    	}
#ifdef ENABLE_BLUETOOTH	
	if(bt_play_flag&&Quit_flag)
	{
		ReloadLogo();
		GUIShowWindow(WinDeviceSelect);
		bt_play_flag = 0;
	}
	if(!Quit_flag)
	Quit_flag=1;
#endif
}



int PICDecodingFinished()
{
	if(jpginfo.picture_type !=1)  
		return 1; //if not baseline jpeg,can break decoding any time;
	if(Pic_Decode_Percent == 100)
		return 1; //finished 
	else 
		return 0; //running
	
}

void PicHideWinControl(PHWND hwnd)
{
	if(hwnd){
			if(hwnd==AWFindWinCtrlByName(PicInfoBar)){
			if(AWIsVisibleWinControl(hwnd)){
			AWClearRectTxt(hwnd->winrect.left,hwnd->winrect.top,hwnd->winrect.width,hwnd->winrect.height);
			hwnd->style |= WS_DISVISIBLE;
			}
		}else{
		if(hwnd==AWFindWinCtrlByName(MiniBar)){
			hwnd->draw_info[0].draw_data = (INT32U)ICON_MINIBAR_TRANS;
			hwnd->draw_info[1].draw_data = (INT32U)0;
			hwnd->draw_info[2].draw_data = (INT32U)0;
			hwnd->draw_info[3].draw_data = (INT32U)0 ;
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 0);
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 1);
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 2);
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 3);
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
		}
		}
	}
}

void AWPICKeyDo(INT32S key)
{
    PCMDSET pCmd ;
    int i;
    INT32U command_value = 0 ;
    switch(key)
    {
    	case UOP_UP:
    	case UOP_LEFT:
    		PHWND hwnd = AWFindWinCtrlByName(PicInfoBar);
    		if(!zoomlevel&&!ShowSixPicFlag&&!AWIsVisibleWinControl(hwnd)){
    		key=UOP_PREVIOUS_CHAP;
    		goto prev;
    	}
    		break;
    	case UOP_DOWN:
    	case UOP_RIGHT:
    		PHWND hwndpic = AWFindWinCtrlByName(PicInfoBar);
    		if(!zoomlevel&&!ShowSixPicFlag&&!AWIsVisibleWinControl(hwndpic)){
    		key=UOP_NEXT_CHAP;
    		goto next;  
    	}
    		break;
    	case UOP_END_PAUSE:
    		if(PicPlayStatus==PIC_PLAY){
			key=UOP_PAUSE;
			goto pause;       		
		}else{
			key=UOP_END_PAUSE;       			            			
		}
			UpdatePicInfoBarIcon(pic_panel_flag,PIC_PANEL_PLAYPAUSE);       	
			pic_panel_flag=PIC_PANEL_PLAYPAUSE;
			if(auto_scroll_timer){
				AVTimerDelete(auto_scroll_timer);
				auto_scroll_timer= 0;
    			}
    			 if(caption_moving_timer){
				AVTimerDelete(caption_moving_timer);
   				caption_moving_timer= 0;
    			}
       			break;
				
       	case UOP_MUTE:       		 
       	if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
     		INT8U audio_app_id;
     		if (AWGetAppID(MEDIA_GENERAL, &audio_app_id) == 0){     			
                if (AWGetAppStatus(audio_app_id) == APP_RUNNING){            	    
                	      		
     	             	UpdateMuteInfo();
     	            }
     	          }
     	        }
     	        break;
     	 case UOP_ANGLE:
     			UpdatePicInfoBarIcon(pic_panel_flag, PIC_PANEL_RIGHT);
     			uop_angle_flag=1;
     			break;
     	case UOP_VOL_MINUS:
     	case UOP_VOL_PLUS:
     		if(isMute == MUTE)
				isMute = UNMUTE ;
			
			if(GPIO_MUTE_STATUS)
				GPIO_MB_UNMUTE;
     	if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
     		INT8U audio_app_id;
     		if (AWGetAppID(MEDIA_GENERAL, &audio_app_id) == 0){
                if (AWGetAppStatus(audio_app_id) == APP_RUNNING){
                		//audio=1;
     	             	UpdateVolumeInfo();
     	            }
     	          }
     	        }
     	        break;
     	case UOP_AUDIO:
		if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
			INT8U audio_app_id;
			if (AWGetAppID(MEDIA_GENERAL, &audio_app_id) == 0){
				if (AWGetAppStatus(audio_app_id) != APP_RUNNING){
					//char *dir_path ;
					//dir_path = FileNavGetCurrDir();
					if(check_media_file_exist(CurDriver,(AW_AUDIO_LIST),0x300|0x1)){
						audio=1;   			   
						UpdateAudioInfo();
						ComboPlayMP3_CurDriver();
						key =UOP_END_PAUSE;
					}
				}
				else{
					if(audio==0)
					AWGPLAYERQuitProcess();  
     				}    			          	
     			}
     		}
     	
     		break;
     	case UOP_ENTER:
#ifndef KOREAR_REMOTE
     	if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
		key = UOP_OSD ;
        	goto osd;
        	}
#endif
        if(auto_scroll_timer){
    		AVTimerDelete(auto_scroll_timer);
		auto_scroll_timer= 0;
    		}
    	if(caption_moving_timer){
    		AVTimerDelete(caption_moving_timer);
		caption_moving_timer= 0;
    		}
           break;
		   
         case UOP_STOP:
            send_pic_player_quit();
		AWPICQuitProcess();  
		DeleteTimer();
		pic_panel_flag=PIC_PANEL_PLAYPAUSE;
			break;   		
        case UOP_RESUME:
        	PHWND hwnd1= AWFindWinCtrlByName(PicInfoBar);
        	if((AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName(WinPicInfoBar))&&AWIsVisibleWinControl(hwnd1)){
			key=UOP_OSD;
			goto osd;
		}else{
            send_pic_player_quit();
			AWPICQuitProcess();  
			DeleteTimer();
			pic_panel_flag=PIC_PANEL_PLAYPAUSE;
		}
			break;	
			
  osd:  case UOP_OSD:  	
  		PHWND dir_hwnd = AWFindWinCtrlByName(PicInfoBar);
		if(dir_hwnd){
    	  if (!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){    	        	
		if(AWIsVisibleWinControl(dir_hwnd)){    					
			PicHideWinControl(dir_hwnd);
    	            	cleanminibarpara();
    	            	cleaninfobarpara();
    	    	}else{
			AWShowWinControl(dir_hwnd,0);
			AWSetFocus(dir_hwnd);
			PicInfobarTimerStart(7000,auto_play_timer_cb);
			#ifndef WISTAR_VERSION
			key=UOP_PAUSE; 
			goto pause;             
			#endif
    		       }
    	      }
#ifdef ENABLE_BLUETOOTH
	if(bt_play_flag)
		{
		if(AWIsVisibleWinControl(dir_hwnd)){    					
			AWClearRectTxt(dir_hwnd->winrect.left,dir_hwnd->winrect.top,dir_hwnd->winrect.width,dir_hwnd->winrect.height);
			dir_hwnd->style |= WS_DISVISIBLE;
    	    	}else{
			AWShowWinControl(dir_hwnd,0);
			AWSetFocus(dir_hwnd);        
    		       }
		}
#endif
    	    }
    	      break;
       case UOP_FAST_FORWARD:
       	key=UOP_NEXT_CHAP;
       	goto next;       
       case UOP_FAST_BACKWARD:
       	key=UOP_PREVIOUS_CHAP;
       	goto prev;
 next:  case  UOP_NEXT_CHAP: 
 			
 			if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))			
				UpdatePicInfoBarIcon(pic_panel_flag,PIC_PANEL_NEXT_CHAP);
       		 break;    
 prev:  case UOP_PREVIOUS_CHAP:

 			if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
				UpdatePicInfoBarIcon(pic_panel_flag,PIC_PANEL_PREV_CHAP);
       		break;	
 pause:  case UOP_PAUSE:
     
       		break;
		#ifdef ZOOM_IN
		 case UOP_ZOOM_IN:
		 if(PicResetZoomLevel())
		 {
             	pCmd = AWCommandSetMalloc() ;
                pCmd->command_num = 1 ;
                pCmd->curr_executed_cmd_num = 0 ;
                pCmd->commands[0] = CM_ZOOM_RETURN;
                pCmd->commands_para[0] = 0;
                pCmd->cmd_timeout_value[0] = 2 ;
                AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
                pCmd->ExecuteResultProcess = PicCmdResponse ;
                AWAddCommandSet(pCmd) ;		 
		 }else{
   		 if(PicPlayStatus==PIC_PLAY){
   		 key=UOP_PAUSE;
   		 }
		  reduce_level++;
		  if(reduce_level>3)
			  reduce_level = 0;
		  AW_SetVideoZoomDown(reduce_level);
		 }
		break;
		#endif
       	default :
       		break;
       	}                 
    	for (i=0; i< PIC_UOP_NUM; i++) {  	
    		if((key == UOP_ANGLE)||(key== UOP_TITLE)){    		
    			if(PICDecodingFinished()){
    				restore_key = 0 ;
    			
    			}else {    		
    				restore_key  = key;
    				key = 0;
    				break;
    			}
    		} 
    	if((key == UOP_NEXT_CHAP) || (key == UOP_PREVIOUS_CHAP)){
    		  if(PICDecodingFinished()){
    			restore_key = 0 ;
    			 			
    		}else{ 
			int focus_flag=(OldFocus%SHOW_WINDOW_NUM);
			if(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)) 
				return;
			PHWND hwnd = AWFindWinCtrlByName(W15PicBar) ;
			if(!hwnd)
				return;
			hwnd->draw_info[focus_flag+2].draw_data = (INT32U)ICON_PIC_FOCUS;
			AWPostMessage(hwnd,WM_PAINT_DRAW_INFO,i+2);         
			AWPostMessage(hwnd,WM_PAINT_FINISH,0);    		
			restore_key  = key;
			aw_title_num=OldFocus;
			key = 0;
			break;
    			}
    		}    	
        if((key == UOP_NEXT_CHAP) || (key == UOP_PREVIOUS_CHAP)) {
            if(pic_processing_status == PIC_STATUS_SKIPPING) {
                return ;
            }
        }      
        if (uop_op[i].uop == key) {
            if (uop_op[i].func) {
                uop_op[i].func();
            }
            switch(key){
			case UOP_ZOOM:
			#ifdef ZOOM_IN
			if(reduce_level != 0){
				reduce_level = 0;
				AW_SetVideoZoomDown(reduce_level);
				return;
			}			
			#endif
	    	case UOP_ANGLE:
	    		command_value = 0;
	    		break;
		case UOP_LEFT:
		case UOP_RIGHT:
		case UOP_UP:
		case UOP_DOWN:
			command_value=0;
			break;
	    	default:
	    		command_value = (INT32U)&six_pic_focus ; 
	    		break;	
			}
            if (uop_op[i].timeout) {
                pCmd = AWCommandSetMalloc() ;
                pCmd->command_num = 1 ;
                pCmd->curr_executed_cmd_num = 0 ;
                pCmd->commands[0] = uop_op[i].cmd ;
                pCmd->commands_para[0] = command_value;
                pCmd->cmd_timeout_value[0] = uop_op[i].timeout ;
                AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
                pCmd->ExecuteResultProcess = PicCmdResponse ;
                AWAddCommandSet(pCmd) ;
            }
           
        }
    } 
    return ;
}

void AWPICKeyProcess(AWMSG *pMsg)
{
    if((pic_processing_status == PIC_STATUS_QUITTING) ||
       (pic_processing_status == PIC_STATUS_SWITCHING)) { // no key responding during App quit processing
        return ;
    }
    AWPICKeyDo(pMsg->msg_value) ;
}

static INT8U PlayPICIndex(int index, unsigned title_flag, unsigned page_start)
{  
	#ifdef ENABLE_NETWORK
	if(pic_playmode==5)
	{
		UpdatePreviewShow(preview_index,1);
		if(preview_index<preview_max_num)
		{
			PreviewNextFile();
		}
		else
		{
			quit_flag = 0xfe;
			send_pic_player_quit();
			AWPICQuitProcess();
		}
		return 0;
	}
	#endif

	if(PicDefineMode_flag==1){
		AVTimeDly(40);
		send_pic_player_quit();
		AWPICQuitProcess();
		AVTimeDly(50);
		return 0;
	}
    int next_index = -1;
    int total_item = 0;
    if (index < 0) {
        total_item = AWGetPlaylistTotalItems2(pic_player_playlist);
        if(total_item > 0 ){
            index = total_item -1 ;
        }else{
        index = 0 ;
        }
    } 

    if (AWGetNthPlaylistItem2(pic_player_playlist, index) != PLAYLIST_STATUS_ASYNCH) {

        if ((aw_title_mode) && ((title_flag & 3)== 3)) {
            /* start page with current decoding picture for page start request */
            next_index = AWGetCurrentPlaylistIndex(pic_player_playlist);
        }
        else if (!aw_title_mode) {
            /* slide show to end of the play list, loop */
            next_index = 0;
        }

        /* playlist to end ,if not in title, start play zero*/
        if (next_index >= 0) {
            if (AWGetNthPlaylistItem2(pic_player_playlist,
                next_index) != PLAYLIST_STATUS_ASYNCH) {
                /* something error.*/
                send_pic_player_quit();
                AWPICQuitProcess();
            }
        }
    }
    else {
        aw_title_last_index = index ;
    }

    set_pic_par(NULL,0,title_flag);

    return 0;
}


void GetPicInfo(unsigned char* pic_info_stream)
{
	pic_disp_info_t *jpginfo_p=NULL;
	jpginfo_p= (pic_disp_info_t *)pic_info_stream;
	jpginfo.file_size   =   jpginfo_p->file_size;
	jpginfo.width       =   jpginfo_p->width ;
	jpginfo.height      =   jpginfo_p->height ;
	jpginfo.bit_count   =   jpginfo_p->bit_count ;
	jpginfo.color_type  =   jpginfo_p->color_type ;
	jpginfo.picture_type=   jpginfo_p->picture_type ;	
	memcpy(jpginfo.time_info,jpginfo_p->time_info,21*sizeof(unsigned char));
}

void GetFileName(char*FileName)
{
	char *p = NULL;
	p = strrchr(FileName, '/');		
	sprintf(FomatName,"%s",p+1);
	sprintf(SixPicName,"%s",p+1);
 }
	
void FormatFileName83(char *FileName)
{
    char *pStr = FileName;
    unsigned char Strlen =0;
    Strlen = strlen(SixPicName);
    if(Strlen>12)
    {
        pStr[7] = '~';
        pStr[8] = SixPicName[Strlen-4];
        pStr[9] = SixPicName[Strlen-3];
        pStr[10] = SixPicName[Strlen-2];
        pStr[11] = SixPicName[Strlen-1];
        pStr[12] = 0;
    }
}

void FormatFileName233(char *FileName)
{
	char *pStr = FileName;
    unsigned char Strlen = strlen(SixPicName);
   if(Strlen>27)
    {
	pStr[22] = '~';
	pStr[23] = SixPicName[Strlen-4];
	pStr[24] = SixPicName[Strlen-3];
	pStr[25] = SixPicName[Strlen-2];
	pStr[26] = SixPicName[Strlen-1];
	pStr[27] = 0;
    }
}

timecheck MyCheck[]=
{
	{"Jan","01"},
	{"Feb","02"},
  	{"Mar","03"},
  	{"Apr","04"},
  	{"May","05"},
  	{"Jun","06"},
  	{"Jul","07"},
  	{"Aug","08"},
  	{"Sep","09"},
  	{"Oct","10"},
  	{"Nov","11"},
  	{"Dec","12"}
};


void TransTime(unsigned char* timeget)
{
	timecheck *Check=MyCheck;
	if((infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.time_info[0])!=0)
	{
		TimeInfo *second=NULL;
		second=(TimeInfo *)timeget;
		memcpy(Time.year,second->year,4*sizeof(char));
		memcpy(Time.month,second->month,2*sizeof(char));
		memcpy(Time.day,second->day,2*sizeof(char));
		memcpy(Time.hour,second->hour,2*sizeof(char));
		memcpy(Time.min,second->min,2*sizeof(char));
		memcpy(Time.sec,second->sec,2*sizeof(char));
	}
else
{
	FirstTime *fist=NULL;
	fist=(FirstTime*)timeget;
	while (Check->Emon) {
        if ((fist->month) && (strncasecmp(fist->month, Check->Emon, 3) == 0)) {
            memcpy(Time.month,Check->Hmon,2*sizeof(char));
            break;
          }
       Check++;
      }
  	memcpy(Time.year,fist->year,4*sizeof(char));
  	memcpy(Time.day,fist->day,2*sizeof(char));
	memcpy(Time.hour,fist->hour,2*sizeof(char));
	memcpy(Time.min,fist->min,2*sizeof(char));
	memcpy(Time.sec,fist->sec,2*sizeof(char));	
}
	Time.A='/';
	Time.B='/';
	Time.C=' ';
	Time.D=':';
	Time.E=':';
	memcpy(ShowTime,&Time,19*sizeof(char));
//ShowTime=(char *)&Time;
}

void Refresh_SixPicFileTime(void)
{
	int filenametop;
    filenametop=GetFileNameTop();
	if(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)) 
		return;
	PHWND hwnd = AWFindWinCtrlByName(W15PicBar) ;
	if(!hwnd)
		return;
	if((infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.time_info[0])==0)
		TransTime(picshowtime);
	else
		TransTime(infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.time_info); 
	hwnd->draw_info[SHOW_WINDOW_NUM+7].draw_data = (INT32U) ShowTime; 
	hwnd->draw_info[SHOW_WINDOW_NUM+6].draw_data = (INT32U) ICON_TIME_BACGROUND; 
   	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+6);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+7);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0); 
}

static void auto_scroll_timer_cb(void *arg)
{
	PHWND hwnd = AWFindWinCtrlByName(W15PicBar) ;
	if(!hwnd)
		return;
	int filenametop;
    filenametop=GetFileNameTop();
    if(auto_scroll_timer){
		AVTimerDelete(auto_scroll_timer);
   		auto_scroll_timer= 0;
	}
	hwnd->draw_info[SHOW_WINDOW_NUM+7].draw_data = (INT32U) ShowTime; 
	hwnd->draw_info[SHOW_WINDOW_NUM+6].draw_data = (INT32U) ICON_TIME_BACGROUND;     
	hwnd->draw_info[SHOW_WINDOW_NUM+4].draw_data = (INT32U)ICON_PHOTO_INFO_BACKROUNG;
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+4);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+6); 
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+7);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0); 
    
	vosd_selfroll_string(hwnd, 
						 SHOW_WINDOW_NUM+8, 
						 SixPicName, 
						 80, 
						 filenametop, 
						 &caption_moving_timer, 
						 caption_moving_time_func, 
						 hwnd->draw_info[SHOW_WINDOW_NUM+8].draw_width ,
						 MOVING_VOSD_LEFT_ROLL, 
						 UNROLL
						 ); 
	 
	
}

static void Refresh_SixPicFileName(void)
{
    INT32S TotalPages = 0;
    INT32S CurrentPage = 0;
    int filenametop;
    filenametop=GetFileNameTop();
	if(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)) 
		return;
	PHWND hwnd = AWFindWinCtrlByName(W15PicBar) ;
	if(!hwnd)
		return;
	if(TotalPicNum%SHOW_WINDOW_NUM)
		TotalPages = TotalPicNum/SHOW_WINDOW_NUM+1;
	else
		TotalPages = TotalPicNum/SHOW_WINDOW_NUM;
	if((aw_title_num+1)%SHOW_WINDOW_NUM)
		CurrentPage = (aw_title_num+1)/SHOW_WINDOW_NUM+1;
	else
		CurrentPage = (aw_title_num+1)/SHOW_WINDOW_NUM;
	UpdateSixPicFocus( hwnd,aw_title_num);
	SixPicNumInfo[0] = ' ';
	sprintf(SixPicNumInfo,"%d/%d", CurrentPage,TotalPages) ;
	static char PicHeightWidth[20];
	PicHeightWidth[0]='0';
	GetFileName(infos[aw_title_num%SHOW_WINDOW_NUM].SixPicFileName); 

#ifdef TV_MODE_1080P
    if((GetSystermMode()==DISPCTL_MODE_1080P)||(GetSystermMode()==DISPCTL_MODE_1080I))
    {
		FormatFileName233(FomatName);	
	}
	else
#endif
#ifdef TV_MODE_720P
    if(GetSystermMode()==DISPCTL_MODE_720P)
    {
		FormatFileName233(FomatName);	
	}
	else
#endif
		FormatFileName83(FomatName);
    sprintf(PicHeightWidth,"%dX%d",infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.height,infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.width);
    hwnd->draw_info[SHOW_WINDOW_NUM+3].draw_data = (INT32U) SixPicNumInfo;
    hwnd->draw_info[SHOW_WINDOW_NUM+5].draw_data = (INT32U) FomatName;     
    if((infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.time_info[0])==0)
		TransTime(picshowtime);
    else
		TransTime(infos[aw_title_num%SHOW_WINDOW_NUM].picinfo.time_info);   
	hwnd->draw_info[SHOW_WINDOW_NUM+7].draw_data = (INT32U) ShowTime; 
	hwnd->draw_info[SHOW_WINDOW_NUM+6].draw_data = (INT32U) ICON_TIME_BACGROUND;     
	hwnd->draw_info[SHOW_WINDOW_NUM+2].draw_data = (INT32U)ICON_PAGE_BACKROUNG;
	hwnd->draw_info[SHOW_WINDOW_NUM+4].draw_data = (INT32U)ICON_PHOTO_INFO_BACKROUNG;
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+2);    
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+3);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+4);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+5);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+6); 
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, SHOW_WINDOW_NUM+7);   
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
	if(auto_scroll_timer){
		AVTimerDelete(auto_scroll_timer);
   		auto_scroll_timer= 0;
	}
#if (defined TV_MODE_720P)||(defined TV_MODE_1080P)
	if((GetSystermMode()!=DISPCTL_MODE_720P)&&(GetSystermMode()!=DISPCTL_MODE_1080P)&&(GetSystermMode()!=DISPCTL_MODE_1080I))
#endif
	    auto_scroll_timer = AVTimerCreateFlag(2000, auto_scroll_timer_cb, (void *)0, AVTIMER_FLAG_PERIODIC); 
					
            
}


void GetFileTime(char * name)
{
	/*struct stat stat_buf;
	int fd ;
	fd = open(name, O_RDONLY);
	avos_tzset("0:00", 0);
	fstat(fd,&stat_buf);
	pictime.time = stat_buf.st_mtime;
	strftime(picshowtime, sizeof(picshowtime), "%Y %b %d %H:%M:%S",localtime((const int *) &pictime.time));
	close(fd) ;*/
}


void AWPICNotificationProcess(AWMSG *pMsg)
{
	 static recordnum = 0;
    PlaylistItem_t *item;
    Playlist_t *playlist;
    char *p = NULL;

    switch(pMsg->msg_id){
	 	case NM_PIC_ZOOMLEVEL:
		   if(pic_playmode == 5)
				break;
	          zoomlevel=pMsg->msg_value;	          
	          if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
             	if(zoomlevel){ 
        	    UpdatePicInfoBarIcon(pic_panel_flag, PIC_PANEL_ZOOM);        		          			    	               
       		 	} 
            	PicPlayState(NM_PIC_ZOOMLEVEL, pMsg->msg_value);      		 	
        	}
	     break;
        case NM_PIC_REQUEST_PAGE:
		if(pic_playmode == 5)
				break;
        	 recordnum = 0 ;
            PlayPICIndex((int)pMsg->msg_value, 3, 1);
            break;            
            
        case NM_PIC_REQUEST_FILE:
#ifdef ENABLE_BLUETOOTH_OPP
            if (bt_play_flag == 1)
            {
                bt_play_flag = 0;
                if (opp_copy_flag&0x7f)
                    opp_copy_flag--;
                if (opp_copy_flag&0x7f)
                {
                    BTShowFileTransferWin(1);
                } else if (opp_copy_flag&0x80)
                {
                    opp_copy_flag = 0;
                    BTHideFileTransferWin(2);
                    BtSendDevCmd(BT_IOCMD_OPP_RELEASE_FILE_INFO,NULL);
                }
                break;
            }
#endif
            if (!aw_title_mode) {
                //if (aw_title_pause == 0) 
                
                    /* get next file name for normal slideshow display */
                    PlayPICIndex((int)pMsg->msg_value, 0, 0);
               
            }
            else {
                /* transition from title play to normal slideshow */
                 PlayPICIndex(pMsg->msg_value, 0, 0);
            }
            break ;
            
        case NM_PIC_REQUEST_DEFAULT_FILE: 
		if(pic_playmode == 5)
				break;
        	send_pic_default_file();        	        		
        	break;
        case NM_PIC_REQUEST_TITLE:
	     if(pic_playmode == 5)
				break;
            if (aw_title_mode) {
                /* get next play item for title display */
                PlayPICIndex(pMsg->msg_value, 2, 0);
            }
            break ;

        case NM_GET_NEXT:
            if((pic_processing_status == PIC_STATUS_QUITTING) ||
               (pic_processing_status == PIC_STATUS_SWITCHING)) { // no key responding during App quit processing
                break ;
            }
            pic_processing_status = PIC_STATUS_SKIPPING;
            if(AWGetNextPlaylistItem2(pic_player_playlist) != PLAYLIST_STATUS_ASYNCH) {
                if(aw_title_mode) {
                }
                else if (AWGetNthPlaylistItem2(pic_player_playlist,
                    0) != PLAYLIST_STATUS_ASYNCH) {
                    /* something error.*/
                    send_pic_player_quit();
                    AWPICQuitProcess();
                }
            }
            break ;

        case NM_GET_PREV:
            if((pic_processing_status == PIC_STATUS_QUITTING) ||
               (pic_processing_status == PIC_STATUS_SWITCHING)) { // no key responding during App quit processing
                break ;
            }
            pic_processing_status = PIC_STATUS_SKIPPING;
            if(AWGetPrevPlaylistItem2(pic_player_playlist) != PLAYLIST_STATUS_ASYNCH) {
                send_pic_player_quit();
                AWPICQuitProcess();
            }
            break ;
        case NM_PIC_TITLE_SELECT_CHANGE:
	     if(pic_playmode == 5)
				break;
            if (aw_title_mode) {
                /* get current select file offset in current play list */
                aw_title_num = pMsg->msg_value &0xffff ;
                aw_curwin_num = (pMsg->msg_value &0xffff0000)>>16 ;
                if(auto_scroll_timer){
					AVTimerDelete(auto_scroll_timer);
   					auto_scroll_timer= 0;
					}
				if(caption_moving_timer){
					AVTimerDelete(caption_moving_timer);
   					caption_moving_timer= 0;
   				}					
                GetFileTime(infos[aw_title_num%SHOW_WINDOW_NUM].SixPicFileName);
                Refresh_SixPicFileName();
                select_change_flag = 1;
            }
            break;            
        case NM_PIC_DECODE_PROGRESS:
		    Pic_Decode_Percent = pMsg->msg_value ;
			if ((MultiMenuToSingle == 2)&&(!aw_title_mode)){
                HWND *hwnd = AWFindWinCtrlByName(Win15Pic) ;
                clear_current_screen();                
                 MultiMenuToSingle=0;
                if (hwnd==NULL)
                    return;
                else{
                    GUIHideWindow(Win15Pic); 
                    if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    				ShowWinPicInfoBar();                      
                }
            }   
			else if ((MultiMenuToSingle == 1)&&(!aw_title_mode)){
                    HWND *hwnd = AWFindWinCtrlByName(Win15Pic) ;
                     MultiMenuToSingle=0;
                    if (hwnd==NULL)
                        return;
                    else{
                    	if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName(Win15Pic))
                        GUIHideWindow(Win15Pic);
                        if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    					ShowWinPicInfoBar();                        
                    }
                }//hide Win15Pic on pic_play starting 
            if(FileMenuToSingle == 2){
                HWND *hwnd = AWFindWinCtrlByName(WinFileList) ;
                FileMenuToSingle = 0 ;
                if (hwnd==NULL)
                    return;
                else{

                    if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    				ShowWinPicInfoBar();                     
                } 
            }
		    if(!Music_Pic_mix_flag) {
               // UpdatePicPlayStatusControl(-1, pMsg->msg_value) ;
            }
			#if 0//def ENABLE_BLUETOOTH_OPP
			if(Pic_Decode_Percent == 100&&opp_copy_flag>0)
			{
				opp_copy_flag --;
			}
			#endif
            break ;

		case NM_PIC_STATUS:
		if(pic_playmode == 5)
				break;
            if (pMsg->msg_value == PIC_PAUSE) {
                aw_title_pause = 1;                
            }
            else {
                aw_title_pause = 0;
            }
            PicPlayStatus=pMsg->msg_value;
			if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
		    PicPlayState(NM_PIC_STATUS, pMsg->msg_value);	
		    UpdatePlayStatus(pMsg->msg_value);
		}     
		   	break;
        case NM_PIC_SIZEINFO :
/*            if(Music_Pic_mix_flag) {
                UpdateMusicPicutreResolution(pMsg->msg_value) ;
            }
            else*/ {
   			   // UpdatePicutreResolution(pMsg->msg_value) ;
   			}
   			
   			break;
   		   	
   		case NM_PIC_DETAIL_INFO:
		if(pic_playmode == 5)
				break;
      		 GetPicInfo((unsigned char*)pMsg->msg_value);
	   
		  if(ShowSixPicFlag==1)
    		{
    		int num = (recordnum > 0)?(recordnum-1):0;
            memcpy(&(infos[num].picinfo), &jpginfo, sizeof(pic_disp_info_t));
            if(recordnum>SHOW_WINDOW_NUM-1)
    		        recordnum = 0;
    	    }
    	    if(ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName(Win15Pic))){
    	  		if(select_change_flag){
    	  			select_change_flag = 0 ;
    	  			Refresh_SixPicFileTime();  
    	  		}
    		}
   		break;
   		case NM_PIC_DISPLAY_NAME_UPDATE:
			if(pic_playmode == 5)
				break;
   			if ((MultiMenuToSingle == 1)&&(!aw_title_mode)){
                    HWND *hwnd = AWFindWinCtrlByName(Win15Pic) ;
                     MultiMenuToSingle=0;
                    if (hwnd==NULL)
			{
				#ifdef ENABLE_NETWORK
				    hwnd = AWFindWinCtrlByName("Win15Pic_net") ;
				    if(hwnd==NULL)
				        return;
				    else
				    {
					    GUIHideWindow("Win15Pic_net");                       
					    if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName("Win15Pic_net")))
						    ShowWinPicInfoBar();                        
				    }
				#endif
				}
                    else{
                    	if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName(Win15Pic))
                        GUIHideWindow(Win15Pic);
                        if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    					ShowWinPicInfoBar();                        
                    }
                }
             if(FileMenuToSingle == 1){
                HWND *hwnd = AWFindWinCtrlByName(WinFileList) ;
                FileMenuToSingle = 0 ;
                if (hwnd==NULL)
                    return;
                else{
                    
                     if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
    					ShowWinPicInfoBar();                    
                } 
            }
            if((ShowSixPicFlag==0)&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic)))
            	{
            		if(!pMsg->msg_value)
            			{
		            		memcpy(PicInfoBarFileName,gCurOnlyFileName,256);
		            		GetFileName(PicInfoBarFileName);
		            		FormatFileName83(FomatName);
		            		HWND *hwnd = AWFindWinCtrlByName(PicInfoBar);
		            		if(hwnd){
							hwnd->draw_info[7].draw_data = (INT32U)ICON_INFOBAR_STATUS140 ;
							hwnd->draw_info[8].draw_data = (INT32U)FomatName;			               
							hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 7);
							hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 8);							  
    						hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
    					}
    						//if(AWIsVisibleWinControl(hwnd)) 			             
			               // vosd_selfroll_string(hwnd, 8, SixPicName,350, 5, &PIC_caption_moving_timer_1, PIC_caption_moving_time_func_1, 0);  
            	 }
            	else
            	{
			         if(gCurOnlyFileName[0] == 0)
			         	{/*first play*/
				        memcpy(PicInfoBarFileName,gCurOnlyFileName,256);
				      	GetFileName(PicInfoBarFileName);
				         }
				       }
                       
           }
                      		
	              break;
	       case NM_PIC_ROTATION_LEVEL:
		   	if(pic_playmode == 5)
				break;
	       	   rotatelevel=pMsg->msg_value;
	       	   if(!ShowSixPicFlag&&(AWGetTopWindow(gpFocusWin) != AWFindWinCtrlByName(Win15Pic))){
            	 PicPlayState(NM_PIC_ROTATION_LEVEL, pMsg->msg_value);  
           		} 
	       	break;
	       	
        case NM_PLAY_PIC:
        case NM_PLAY_GENERAL:
            if(!pMsg->msg_value) {
                send_pic_player_quit();
                AWPICQuitProcess();
                break;
            }
			#ifdef ZOOM_IN
			if(reduce_level !=0)
			{
				reduce_level = 0;
				AW_SetVideoZoomDown(reduce_level);
			}
			#endif
            playlist = (Playlist_t *)pMsg->msg_value;
            AWUnLockPlaylist(playlist);
            if(AWPlaylistIsInvalid(playlist)) {
                if((INT32U)pic_player_playlist == (INT32U)playlist) {
                    pic_player_playlist = NULL;
                }
                AWPlaylistDelete2(playlist);
                break ;
            }
            item = AWGetCurrentPlaylistItem2(playlist);
            if(item) {
	          p = strrchr(item->location, '/');		
                //sprintf(gCurOnlyFileName,"%s",p+1);
               memcpy(gCurOnlyFileName,item->location,256*sizeof(char)); 
                if(pic_processing_status == PIC_STATUS_SKIPPING) {
                    pic_processing_status = PIC_STATUS_RUNNING;
                }
                load_picapp_data[1] |= AWGetCurrentPlaylistIndex(pic_player_playlist) << 2;
    		if(ShowSixPicFlag==1)
    		{
    		    strcpy(infos[recordnum].SixPicFileName,gCurOnlyFileName);
    		    recordnum++;
    	    }
    		if(title_flag)
    		{
    			send_pic_player_file_title();
    			title_flag=0;
		}	
		else
                send_pic_player_file(item->location);	
            } else {
                send_pic_player_quit();
                AWPICQuitProcess();
            }
            break ;
#ifdef ENABLE_BLUETOOTH
 case NM_END_OF_PLAY:
 		quit_flag = (INT8U)pMsg->msg_value;
 		CleanMiniBar();
    		GUIHideWindow(WinPicInfoBar);
 		Quit_flag=0;
		send_pic_player_quit();
		AWPICQuitProcess();
		break;	
#endif
        default:
            break ;
    }
    return ;
}


void AWPICBroadCastProcess(AWMSG* pMsg)
{
	CHARSTR* temp;
	CHARSTR* dev_str = NULL; 
	CHARSTR* path = NULL; 
	if(pMsg->msg_id==BM_DEVICE_PRE_UNMOUNT)
	{
		temp=((DEV_MOUNT_INFO *)(pMsg->msg_value))->mount_point_name;
		dev_str = ((DEV_MOUNT_INFO *)(pMsg->msg_value))->mount_device_type;
		path = FileNavGetCurrDir();

		if (strncmp(PicGetCurrentPlayingName(0), temp, strlen(temp)) == 0)
		{
			SetForceCloseMediaApp();
			 device_removed = 1; // move this line before "AWPICKeyDo(UOP_STOP)" because AWPICQuitProcess() will be called in "AWPICKeyDo(UOP_STOP)"
            		UnMount = 1;
			  uop_home_flag = 1;		
			AWPICKeyDo(UOP_STOP);
		}            
	}        
#ifdef ENABLE_BLUETOOTH_OPP
    else if (pMsg->msg_id == BM_DEVICE_BT_CONNECT)
    {
        if (!strcmp(nand_name, "nanda1"))
        {
            SetBtStatus(BLUETOOTH_OPP,BM_DEVICE_BT_CONNECT);
            device_removed=1;
            send_pic_player_quit();
            AWPICQuitProcess();
        }
    }
#endif
#ifdef ENABLE_BLUETOOTH_FTP
    else if (pMsg->msg_id == BM_DEVICE_BT_REMOVE)
    {
        if (strcmp(file_current_addr,btftp_pathname) == 0)
        {
            device_removed=1;
            send_pic_player_quit();            
            AWPICQuitProcess();
        }
    } else if (pMsg->msg_id == BM_DEVICE_BT_DEV_DOWN)
    {
        if (strcmp(file_current_addr,btftp_pathname) == 0)
        {
            device_removed=1;
            send_pic_player_quit();
            AWPICQuitProcess();
        }
    }
#endif
//    AWSysBroadCastProcess(pMsg);       
}    

void AWPICMsgProcess(AWMSG *pMsg)
{	
    switch(pMsg->msg_type){
        case MSG_INPUT_EVENT:
            if(pMsg->msg_id == WM_KEYDOWN){
                AWPICKeyProcess(pMsg) ;
            }
            break ;
        case MSG_NOTIFICATION:
            AWPICNotificationProcess(pMsg) ;
            break ;
        case MSG_QUIT:	
            AWPICQuitProcess2(pMsg);
#ifdef ENABLE_BLUETOOTH_OPP
            if(opp_copy_flag&0x80)
            {
                opp_copy_flag = 0;
                BTHideFileTransferWin(2);
                BtSendDevCmd(BT_IOCMD_OPP_RELEASE_FILE_INFO,NULL);
            }
            else if(GetBtStatus(BLUETOOTH_OPP) == BM_DEVICE_BT_CONNECT)
            {
                SetBtStatus(BLUETOOTH_OPP,0);
                BTShowFileTransferWin(0);
            }
#endif
            break;
        case MSG_BROADCAST:
            AWPICBroadCastProcess(pMsg);
            break;    
        default:
            break ;
    }

    return ;
}

void PicParaTrans(void)
{
	INT8U save_pic_slide_show_mode;
	save_pic_slide_show_mode = GetSlideModePara();
	switch(save_pic_slide_show_mode)
		{
		case 0:
			pic_slide_show_mode = -1;///*OFF, no slide show effect */
			break;
		case 1:
			pic_slide_show_mode=SHOW_BOTTOM2TOP;
			break;
		case 2:
			pic_slide_show_mode=SHOW_TOP2BOTTOM;
			break;
		case 3:
			pic_slide_show_mode=SHOW_LEFT2RIGHT;
			break;
		case 4:
			pic_slide_show_mode =SHOW_RIGHT2LEFT;
			break;
		case 5:
			pic_slide_show_mode =SHOW_HORDOORCLOSE;
			break;
		case 6:
			pic_slide_show_mode =SHOW_HORDOOROPEN;
			break;
		case 7:
			pic_slide_show_mode =SHOW_HORINTERCROSS;
			break;
		case 8:
			pic_slide_show_mode=SHOW_VERINTERCROSS;
			break;
		case 9:
			pic_slide_show_mode = 0xff;//randow 
			break;
		case 10:
#ifdef DEMO_SHOW_VPP_EFFECT_SRC_WINDOW
			pic_slide_show_mode = SHOW_VPP_EFFECT_SRC_WINDOW;
#else
			pic_slide_show_mode = SHOW_FADE_OUT_FADE_IN;
#endif
			break;
		deflault:
			break;
			
		}
	
	INT8U save_pic_slide_time_mode;
	save_pic_slide_time_mode=GetSlideDurPara();
             switch(save_pic_slide_time_mode)
             {
             	case 0:
              case 1:
			pic_watch_dog=save_pic_slide_time_mode+1;
				break;
             	case 2:
			pic_watch_dog=save_pic_slide_time_mode+3;
				break;
             	case 3:
			pic_watch_dog=save_pic_slide_time_mode+4;
				break;
             	case 4:
             	case 5:
			pic_watch_dog=save_pic_slide_time_mode+6;
				break;
             	default:
				break;
		        }
}

INT32S display_multi_pic(void)
{
    Playlist_t *Imageplaylist=NULL;
    INT32U combo_type;
    //INT8U pic_mode;
    //
   // reset_file_node();
    if(!pic_player_playlist){
    	reset_file_node();
    	Imageplaylist=fs_playlist_create(CurDriver,AW_PIC_LIST & NAV_PATH_TYPE , PLAYLIST_TYPE_IMAGE, 0,AUTORUN_DEPTH|0x1,&combo_type);
	}else{
		Imageplaylist = pic_player_playlist;  /*use last time playlist*/
	}
    if(Imageplaylist)
    {
        TotalPicNum = AWGetPlaylistTotalItems2(Imageplaylist);   //huanghonglin 2006-11-1 17:04
        //pic_mode = GetSlideModePara();
        //pic_slide_show_mode = -1;
         PicParaTrans();
        if(RunPICPlayer(Imageplaylist,(unsigned char *)Logo_keyboard, sizeof(Logo_keyboard), 0))
        {
            AWPlaylistDelete2(Imageplaylist);
        }
        return 1;
    }
   else{
	   ShowSixPicFlag = 0 ;
	   return -1;
   	}
}

void SetPicRunStatus(INT8U flag)
{      
       PCMDSET pCmd;
    /*picture first run status  setting*/	
	pCmd = AWCommandSetMalloc() ;
    	pCmd->command_num = 1 ;
    	pCmd->curr_executed_cmd_num = 0 ;
    	pCmd->commands[0] = CM_SET_PIC_PLAY_STATUS;
    	pCmd->commands_para[0] = flag;	
    	pCmd->cmd_timeout_value[0] = 2 ;
    	AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
    	pCmd->ExecuteResultProcess = PicCmdResponse ;
    	AWAddCommandSet(pCmd) ;
}

void clear_current_screen()
{
//	#ifdef CM_CLEAR_SCREEN
        PCMDSET pCmd;
    /*picture first run status  setting*/	
	pCmd = AWCommandSetMalloc() ;
    	pCmd->command_num = 1 ;
    	pCmd->curr_executed_cmd_num = 0 ;
    	pCmd->commands[0] = CM_CLEAR_SCREEN;
    	pCmd->commands_para[0] = 0;	 
    	pCmd->cmd_timeout_value[0] = 2 ;
    	AWGetAppID(MEDIA_PIC, &pCmd->app_id) ;
    	pCmd->ExecuteResultProcess = PicCmdResponse ;
    	AWAddCommandSet(pCmd) ;
//    #endif
}
#ifdef ENABLE_BLUETOOTH
void PicPlayer(char *filename)
{
	INT8U my_app_id ;
    PicInit();
    PicDefineMode_flag = 0;
	bt_play_flag = 1;
	bt_pic_flag = 1;
	ShowSixPicFlag=0;
	user_window[0]=0;
	AWGetAppID(MEDIA_PIC, &my_app_id) ; 
#ifdef USE_NEW_SCREEN_SAVER 
            if(gScreenSaveFlag) {
		  ScrSaverSet(SCREEN_SAVER_OFF) ;
                ScrSaverReset() ;
		  screensaverstop(1);
            }
#endif
    if (AWGetAppStatus(my_app_id) != APP_RUNNING)
    {
        AWAppRunning(my_app_id) ;
        pic_processing_status = PIC_STATUS_RUNNING;
        //PicSysSetting();
        BT_PicSysSetting();
    }
    strcpy(gCurOnlyFileName,filename);
    send_pic_player_file(gCurOnlyFileName);
    set_pic_par(NULL, 0, 0);
    //SetPicRunStatus(1);
    GUIShowWindow(WinPicInfoBar);
}
#endif

#ifdef ENABLE_NETWORK
void Preview15net_quit()
{
	send_pic_player_quit();
//	DeletPicPlayList();
	AWSetFileList(AWFindWinCtrlByName("_AWWindowsRoot_"),NULL,NULL);
    AWPICQuitProcess();
}
#endif

